load("//bzl:cpp_library.bzl", "cpp_library")

package(default_visibility = ["//visibility:public"])

cpp_library(
    name = "at_fork",
    srcs = ["AtFork.cpp"],
    hdrs = ["AtFork.h"],
    deps = [
        "//folly:function",
        "//folly:scope_guard",
        "//folly/lang:exception",
        "//folly/portability:pthread",
        "//folly/portability:sys_types",
        "//folly/synchronization:sanitize_thread",
    ],
)

cpp_library(
    name = "aux_vector",
    hdrs = ["AuxVector.h"],
    deps = [
        "//folly:portability",
        "//folly:preprocessor",
    ],
)

cpp_library(
    name = "env_util",
    srcs = ["EnvUtil.cpp"],
    hdrs = ["EnvUtil.h"],
    deps = [
        "//folly:c_portability",
        "//folly:memory",
        "//folly:string",
        "//folly/portability:stdlib",
        "//folly/portability:unistd",
        "@glog",
    ],
)

cpp_library(
    name = "hardware_concurrency",
    srcs = ["HardwareConcurrency.cpp"],
    hdrs = [
        "HardwareConcurrency.h",
    ],
    deps = [
        "//folly/portability:sched",
    ],
)

cpp_library(
    name = "memory_mapping",
    srcs = ["MemoryMapping.cpp"],
    hdrs = ["MemoryMapping.h"],
    deps = [
        "//folly:file",
        "//folly:portability",
        "//folly:range",
        "//folly/portability:gflags",
        "//folly/portability:sys_mman",
        "//folly/portability:sys_syscall",
        "//folly/portability:unistd",
        "@fmt",
        "@glog",
    ] + select({
        "@platforms//os:linux": ["//folly/experimental/io:huge_pages"],
        "//conditions:default": [],
    }),
)

cpp_library(
    name = "pid",
    srcs = ["Pid.cpp"],
    hdrs = ["Pid.h"],
    deps = [
        ":at_fork",
        "//folly/portability:sys_types",
        "//folly/portability:unistd",
        "@glog",
    ],
)

cpp_library(
    name = "shell",
    srcs = ["Shell.cpp"],
    hdrs = ["Shell.h"],
    deps = [
        "//folly:conv",
        "//folly:format",
        "//folly:range",
    ],
)

cpp_library(
    name = "thread_id",
    srcs = ["ThreadId.cpp"],
    hdrs = ["ThreadId.h"],
    deps = [
        ":at_fork",
        "//folly:likely",
        "//folly/portability:pthread",
        "//folly/portability:sys_syscall",
        "//folly/portability:unistd",
        "//folly/portability:windows",
        "//folly/synchronization:relaxed_atomic",
    ],
)

cpp_library(
    name = "thread_name",
    srcs = ["ThreadName.cpp"],
    hdrs = ["ThreadName.h"],
    deps = [
        "//folly:optional",
        "//folly:portability",
        "//folly:range",
        "//folly:scope_guard",
        "//folly:traits",
        "//folly/portability:config",
        "//folly/portability:pthread",
        "//folly/portability:windows",
    ],
)
